#ifndef _MAN_DRM_H_
#define _MAN_DRM_H_

#include <unistd.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm_fourcc.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string>
#include <iostream>
#include <string.h>
#include <sys/mman.h>

#define DRM_CARD_NAME "/dev/dri/card0"

using namespace std;



class ManDRM {
	
public:
	struct buffer_object {
		uint32_t width;
		uint32_t height;
		uint32_t pitch;
		uint32_t handle;
		uint32_t size;
		uint8_t *vaddr;
		uint32_t fb_id;
		int fd;
	};

	ManDRM();
	~ManDRM();
	void printDRMInfo();
	buffer_object * getBufSwap();
	void drmBuffSwap();
private:
	void _modeSetDestroyFB(int fd, struct buffer_object *bo);
	int _modeSetCreateFB(int fd, struct buffer_object *bo);
	void _writeColor(struct buffer_object *bo,unsigned int color);
	int m_fd;
	int m_index;
	buffer_object m_buf[2];
	drmModeConnector * m_conn;
	drmModeRes * m_res;
	drmModePlaneRes * m_plane_res;
	unsigned int m_conn_id;
	unsigned int m_crtc_id;
	unsigned int m_plane_id;
	unsigned int m_x;
	unsigned int m_y;

};



#endif
